package com.example.controller;

import com.example.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 21050134
 * @date: 2023/10/8 13:29
 * @description:
 */
@RestController
@Slf4j
public class DeptController {
	@Autowired
	private DeptService deptService;
	@Value("${server.port}")
	private String serverPort;

	@RequestMapping(value="/dept/hystrix/ok/{id}")
	public String deptInfo_Ok(@PathVariable("id") Integer id){
		String result = deptService.deptInfo_Ok(id);
		log.info("端口号："+serverPort + "result： " + result);
		return result +",端口号："+serverPort;
	}


	@RequestMapping(value="/dept/hystrix/timeout/{id}")
	public String deptInfo_Timeout(@PathVariable("id") Integer id){
		String result = deptService.deptInfo_Timeout(id);
		log.info("端口号："+serverPort + "result： " + result);
		return result +",端口号："+serverPort;
	}


	@RequestMapping(value="/dept/hystrix/circuit/{id}")
	public String deptCircuitBreaker(@PathVariable("id") Integer id){
		String result = deptService.deptCircuitBreaker(id);
		log.info("result： " + result);
		return result;
	}

}
